# -*- coding: utf-8 -*-
from models import Section, Widget
from django.contrib import admin
from django.utils.translation import ugettext as _

from multilingual.admin import MultilingualModelAdmin

class SectionAdmin(MultilingualModelAdmin):
    list_display = ('title', 'slug', 'app', 'parent', 'menuTop')
    list_display_links = ('title', 'slug')
    list_filter = ['app']
    ordering = ['tree_id','level']
    limit_choices_to = ['app']
    search_fields = ['title', 'slug']

    use_prepopulated_fields = {'slug': ('title',)}

    class Media:
        js = (
            "/medias/admin/tinymce/jscripts/tiny_mce/tiny_mce.js",
            "/medias/js/tiny_conf.js",
            )


class WidgetAdmin(MultilingualModelAdmin):
    list_display = ('title', 'slug', 'section', 'link')
    list_display_links = ('title', 'slug')
    search_fields = ['title','slug']

    use_prepopulated_fields = {'slug': ('title',),}

    class Media:
        js = (
            "/medias/admin/tinymce/jscripts/tiny_mce/tiny_mce.js",
            "/medias/js/tiny_conf.js",
            )

admin.site.register(Section, SectionAdmin)
admin.site.register(Widget, WidgetAdmin)
